package com.tensquare.rabbitmq;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author zzb
 * @create 2021/2/22
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class producer01 {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    //1.测试发送direct消息( 直连模式)
    @Test
    public void test01(){
        rabbitTemplate.convertAndSend("zzb","hello,rabbitmq!");
    }
    //分裂模式fanout模式（）
    @Test
    public void test02(){
        rabbitTemplate.convertAndSend("zzb-school","","给交换机发消息");
    }

    //主题模式(测试发送topic消息)
    @Test
    public void test03(){
        rabbitTemplate.convertAndSend("threabooks","goods.aa","正在发送一goods开头的消息");
    }
    @Test
    public void test04(){
        rabbitTemplate.convertAndSend("threabooks","aa.log","正在发送以log结尾的消息");
    }
    @Test
    public void test05(){
        rabbitTemplate.convertAndSend("threabooks","goods.log","正在发送goods开头log结尾的消息");
    }
}
